package com.zzc.keleoj.model.enums;

import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum  JudgeInfoMessageEnum {
//    ACCEPTED("成功", "Accepted"),
//    WRONG_ANSWER("答案错误", "Wrong Answer"),
//    COMPILE_ERROR("Compile Error", "编译错误"),
//    MEMORY_LIMIT_EXCEEDED("", "内存溢出"),
//    TIME_LIMIT_EXCEEDED("Time Limit Exceeded", "超时"),
//    PRESENTATION_ERROR("Presentation Error", "展示错误"),
//    WAITING("Waiting", "等待中"),
//    OUTPUT_LIMIT_EXCEEDED("Output Limit Exceeded", "输出溢出"),
//    DANGEROUS_OPERATION("Dangerous Operation", "危险操作"),
//    RUNTIME_ERROR("Runtime Error", "运行错误"),
//    SYSTEM_ERROR("System Error", "系统错误");
    ACCEPTED("Accepted", 1),
    WRONG_ANSWER("Wrong Answer", 2),
    COMPILE_ERROR("Compile Error", 3),
    MEMORY_LIMIT_EXCEEDED("Memory Limit Exceeded", 4),
    TIME_LIMIT_EXCEEDED("Time Limit Exceeded", 5),
    PRESENTATION_ERROR("Presentation Error", 6),
    WAITING("Waiting", 7),
    OUTPUT_LIMIT_EXCEEDED("Output Limit Exceeded", 8),
    DANGEROUS_OPERATION("Dangerous Operation", 9),
    RUNTIME_ERROR("Runtime Error", 10),
    SYSTEM_ERROR("System Error", 12);

    private final String text;

    private final Integer value;

    JudgeInfoMessageEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<Integer> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static JudgeInfoMessageEnum getEnumByValue(Integer value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (JudgeInfoMessageEnum anEnum : JudgeInfoMessageEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public Integer getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

}
